package com.extr.security.handler;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;

/**
 *项目：广发网
 *版权：Copyright(c)2013
 *公司：广发证券股份有限公司
 *作者：胡纬
 *创建日期：2015-10-23
 *创建时间：下午6:30:57
 *功能描述：
 */
public class ExtrAuthenticationFailedHandler extends SimpleUrlAuthenticationFailureHandler{

    @Override
    public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
            AuthenticationException exception) throws IOException, ServletException {
        if("mobile".equalsIgnoreCase(request.getParameter("j_logintype"))){
            this.setDefaultFailureUrl("/mobile/login?result=failed");
        }else{
            this.setDefaultFailureUrl("/user-login-page?result=failed");
        }
        // TODO Auto-generated method stub
        super.onAuthenticationFailure(request, response, exception);
    }

}
